package thread_test;

// 表示平面上的一个点
class Point {
    // 笛卡尔坐标系 x 与 y
    private double x;
    private double y;
    // 极坐标系 r 与 a
    private double r;
    private double a;
    // 通过笛卡尔坐标系来构造这个点
    public static Point makePointByXY(double x, double y) {
        Point point = new Point();
        point.setX(x);
        point.setY(y);
        return point;
    }
    // 通过极坐标系来构造这个点
    public static Point makePointByRA(double r, double a) {
        Point point = new Point();
        point.setR(r);
        point.setA(a);
        return point;
    }

    public double x() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double y() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double r() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    public double a() {
        return a;
    }

    public void setA(double a) {
        this.a = a;
    }
}
public class PointFactory {
    public static void main(String[] args) {
        Point point1 = Point.makePointByXY(3,4);
        Point point2 = Point.makePointByRA(3,30);
        System.out.println("point1 的笛卡尔坐标:->(" + point1.x() + "," + point1.y() + ")");
        System.out.println("point2 的极坐标:->(" + point2.r() + "," + point2.a() + ")");
    }
}
